var e = getApp();

Page({
    data: {
        companyShow: !1,
        form: {
            refund_id: "",
            express_sn: "",
            express_company: ""
        },
        express: [],
        expressName: "",
        expressCode: ""
    },
    onLoad: function(e) {
        e.refund_id && this.setData({
            "form.refund_id": e.refund_id
        }), this._initData(), this._getExpressInfo();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    scanCode: function() {
        var e = this;
        wx.scanCode({
            onlyFromCamera: !0,
            success: function(s) {
                e.setData({
                    "form.express_sn": s.result
                });
            }
        });
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _initData: function() {
        this.setData({
            companyShow: !1,
            "form.express_sn": "",
            "form.express_company": "",
            express: [],
            expressName: "",
            expressCode: ""
        });
    },
    companyShowbtn: function() {
        this.setData({
            companyShow: !0
        });
    },
    expressclear: function() {
        this.setData({
            "form.express_sn": ""
        });
    },
    expressbtn: function(e) {
        var s = e.detail;
        this.setData({
            "form.express_sn": s
        });
    },
    companyShowClose: function() {
        this.setData({
            companyShow: !1
        });
    },
    _getExpressInfo: function() {
        var s = this, n = e.getNetAddresss("dispatch.express-list");
        e._getNetWork({
            url: n,
            success: function(e) {
                var n = e.data;
                if (1 == n.result) {
                    var t = n.data;
                    s.setData({
                        express: t.express_companies
                    });
                }
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    submitInfo: function() {
        var s = e.getNetAddresss("refund.operation.send");
        s += "&refund_id=" + this.data.form.refund_id, s += "&express_sn=" + this.data.form.express_sn, 
        s += "&express_company_name=" + this.data.expressName, s += "&express_company_code=" + this.data.expressCode, 
        e._getNetWork({
            url: s,
            success: function(e) {
                var s = e.data;
                1 == s.result ? wx.showToast({
                    title: s.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: s.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    companyConfirm: function(e) {
        var s = e.currentTarget.dataset.item;
        this.setData({
            expressName: s.name,
            expressCode: s.value,
            companyShow: !1
        });
    }
});